package router

import (
	controller "gitee.com/wangshh_123/cross-pay-go/src/controller/system"
	"gitee.com/wangshh_123/cross-pay-go/src/middleware"

	"github.com/gin-gonic/gin"
)

// SetupHlPayTransactionCacheRoutes 设置HlPay交易缓存路由
func SetupHlPayTransactionCacheRoutes(r *gin.RouterGroup, cacheController *controller.HlPayTransactionCacheController) {
	// HlPay交易缓存管理路由组
	hlpayCacheGroup := r.Group("/hlpay/transaction-cache")
	hlpayCacheGroup.Use(middleware.AuthMiddleware())
	{
		// 同步交易数据
		hlpayCacheGroup.POST("/sync", cacheController.SyncTransactions)

		// 自动同步检查
		hlpayCacheGroup.POST("/auto-sync", cacheController.AutoSyncWithCheck)

		// 获取当前用户交易记录
		hlpayCacheGroup.GET("/user/transactions", cacheController.GetUserTransactions)

		// 获取卡片交易记录
		hlpayCacheGroup.GET("/card/:card_id/transactions", cacheController.GetCardTransactions)

		// 根据卡昵称查询交易记录
		hlpayCacheGroup.GET("/nickname/:nickname/transactions", cacheController.GetTransactionsByNickname)

		// 根据ID获取交易记录
		hlpayCacheGroup.GET("/user/transactions/:transaction_id", cacheController.GetTransactionByID)

		// 获取缓存统计信息
		hlpayCacheGroup.GET("/stats", cacheController.GetCacheStats)

		// 清理缓存
		hlpayCacheGroup.POST("/clear", cacheController.ClearCache)

		// 获取当前配置
		hlpayCacheGroup.GET("/config", cacheController.GetConfig)

		// 更新缓存配置
		hlpayCacheGroup.PUT("/config", cacheController.UpdateConfig)
	}
}
